package com.ozo.cloud.auth.log;

import com.ozo.cloud.api.system.dto.SysLoginLogDTO;
import com.ozo.cloud.api.system.feign.SysLoginLogFeignClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * 登录事件监听
 *
 * @author qiangesoft
 * @since 2024-07-11
 */
@Slf4j
@RequiredArgsConstructor
@Component
public class LoginLogListener {

    private final SysLoginLogFeignClient sysLoginLogClient;

    @Async
    @EventListener({LoginLogEvent.class})
    public void saveSysLog(LoginLogEvent event) {
        sysLoginLogClient.add((SysLoginLogDTO) event.getSource());
    }

}
